package com.open.capacity.task.utils;

import com.open.capacity.task.dao.TaskDao;
import org.springframework.beans.factory.annotation.Autowired;

public class CodeGenerator {

    /**
     * 根据任务类型自动生成相对应的任务编号(三个表示任务类型的字母+6个表示所有任务数量的数字组成)
     * PUB******:普通任务
     * URG******:紧急任务
     *
     * @return
     */
    public static String Generate(Integer kind, Integer count) {

        String type = null;
        String Number = null;
        switch (kind) {
            case 1:
                type = "URG";
                break;
            case 2:
                type = "PUB";
                break;
            default:
                type = "OTH";
        }   //判断是何种任务，并设置前缀
        if (count == null)
            count = 0;
        if (count >= 0 && count < 10) {
            Number = "00000" + count.toString();
        } else if (count >= 10 && count < 100) {
            Number = "0000" + count.toString();
        } else if (count >= 100 && count < 1000) {
            Number = "000" + count.toString();
        } else if (count >= 1000 && count < 10000) {
            Number = "00" + count.toString();

        } else if (count >= 10000 && count < 100000) {
            Number = "0" + count.toString();
        }
        return type + Number;
    }
}
